﻿using SmartPlant.Model;
using SmartPlant.Services.Interfaces;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

namespace SmartPlant.Services
{
    public class ImportUtilityService : BaseService, IImportUtilityService
    {
        #region 1
        /// <summary>
        /// 索引表导入。
        /// ImportUtilityController/Index
        /// </summary>
        /// <param name="proId"></param>
        /// <param name="reportname"></param>
        /// <param name="path"></param>
        /// <param name="unitid"></param>
        /// <param name="files"></param>
        /// <param name="insttypeinsertflag"></param>
        /// <returns></returns>
        public async Task<RESTfulResult<string>> UploadIndexTableAsync(string proId, string reportname, string path, string unitid, List<NetworkFileInfo> files, bool taginsertflag, bool insttypeinsertflag, bool replaceInstTypeFlag, bool TestMode)
        {
            //var insttypeinsertflag = true;
            var blankvalueupdteflag = false;
            string url = $"/api/Project/{proId}/import-utility-api/index/{reportname}/{path}/{unitid}/{taginsertflag}/{insttypeinsertflag}/{replaceInstTypeFlag}/{blankvalueupdteflag}/{TestMode}";
       
            return await PostFileAsync<string>(url, files);
        }

        /// <summary>
        /// 导入时对比数据内容
        /// </summary>
        /// <param name="proId"></param>
        /// <param name="reportname"></param>
        /// <param name="path"></param>
        /// <param name="unitid"></param>
        /// <param name="files"></param>
        /// <returns></returns>
        public async Task<RESTfulResult<string>> UploadIndexTableAsync(string proId, string reportname, string path, string unitid, List<NetworkFileInfo> files)
        {

            string url = $"/api/Project/{proId}/import-utility-api/indexcompare/{reportname}/{path}/{unitid}";
            return await PostFileAsync<string>(url, files);
        }

        /// <summary>
        /// 数据表导入。
        /// ImportUtilityController/Index
        /// </summary>
        /// <param name="proId"></param>
        /// <param name="reportname"></param>
        /// <param name="path"></param>
        /// <param name="unitid"></param>
        /// <param name="files"></param>
        /// <param name="blankValueUpdteFlag"></param>
        /// <returns></returns>
        public async Task<RESTfulResult<string>> UploadSpecTableAsync(string proId, string reportname, string path, string unitid, List<NetworkFileInfo> files, bool blankValueUpdteFlag, bool TestMode, bool IsCompType = false)
        {
            string url = $"/api/Project/{proId}/import-utility-api/spec/{reportname}/{path}/{unitid}/{blankValueUpdteFlag}/{TestMode}/{IsCompType}";
            //string url = $"/api/Project/{proId}/import-utility-api/Spec/{reportname}/{path}/{unitid}";
            return await PostFileAsync<string>(url, files);
        }
        #endregion
    }
}
